package com.iflytek.day27;


import java.io.*;

public class _05_BufferedStreamDemo {
  public static void main(String[] args) throws IOException {
    // BufferedWriter(Writer out)
    BufferedWriter bw = new BufferedWriter(new FileWriter("src\\com\\iflytek\\day27\\bw.txt"));
    bw.write("hello\r\n");
    bw.write("world\r\n");
    bw.close();
    // BufferedReader(Reader in)
    BufferedReader br = new BufferedReader(new FileReader("src\\com\\iflytek\\day27\\bw.txt"));
    // 一次读取一个字符数据
    // int ch;
    // while ((ch = br.read()) != -1) {
    //   System.out.print((char) ch);
    // }

    // 一次读取一个字符数组数据
    char[] chs = new char[1024];
    int len;
    while ((len = br.read(chs)) != -1) {
      System.out.print(new String(chs, 0, len));
    }

    br.close();
  }
}
